package com.kly.chatter.api.application.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.kly.chatter.api.application.controller.chatter.req.ChatterEditReq;
import com.kly.chatter.api.application.service.ChatterModelInfoExamineService;
import com.kly.chatter.db.dao.ChatterModelInfoExamineDao;
import com.kly.chatter.db.entity.ChatterModelInfoExamineEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class ChatterModelInfoExamineServiceImpl implements ChatterModelInfoExamineService {

    @Autowired
    private ChatterModelInfoExamineDao chatterModelInfoExamineDao;


    @Override
    public void add(ChatterEditReq chatterEditReq) {
        ChatterModelInfoExamineEntity chatterModelInfoExamineEntity = new ChatterModelInfoExamineEntity();
        chatterModelInfoExamineEntity.setUserCode(chatterEditReq.getUserCode());
        chatterModelInfoExamineEntity.setUserInfo(chatterEditReq.getAboutMe());
        chatterModelInfoExamineEntity.setOperateStatus(1);
        chatterModelInfoExamineDao.insert(chatterModelInfoExamineEntity);
    }

    @Override
    public Boolean dealStatus(String userCode) {
        boolean result = true;
        ChatterModelInfoExamineEntity chatterModelInfoExamine = chatterModelInfoExamineDao.getLastRecord(userCode);
        if (chatterModelInfoExamine != null && chatterModelInfoExamine.getOperateStatus() == 1) {
            result = false;
        }
        if (chatterModelInfoExamine == null){
            result = true;
        }
        return result;
    }
}
